package com.samsung.controller.vote;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.samsung.dto.vote.VoteHistoryDto;
import com.samsung.model.vote.VoteTopic;
import com.samsung.service.vote.TopicService;

@Controller
@RequestMapping("/vote")
public class VoteIndexController {
	@Autowired
	private TopicService topicService;

	/**
	 * 
	 * @Title: index
	 * @Description: TODO(获取最新最热投票信息)
	 * @param @param request
	 * @param @param response
	 */
	@RequestMapping({"/index", "/"})
	public ModelAndView index(ModelAndView model) {
		int max = 5;
		
		List<VoteTopic> topicList = topicService.listNewVote(max);
		List<VoteHistoryDto> vhd = topicService.listHotVote(max);
		model.addObject("topicList", topicList);
		model.addObject("listVhd", vhd);
		model.setViewName("vote/index");
		
		return model;
	}

}
